package com.breeze.blockchain.mybatis.entity;

import static com.breeze.blockchain.common.exception.BizErrorCode.USER_ROLE_DISABLE;

import com.breeze.blockchain.common.enums.UserStatusEnum;
import com.breeze.components.mybatis.base.BaseEntity;
import com.fhs.core.trans.anno.TransDefaultSett;
import com.fhs.core.trans.vo.TransPojo;
import com.mybatisflex.annotation.Table;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serial;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * 角色 实体类。
 *
 * @author breeze
 * @since 2024-05-11 23:21:51
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Schema(title = "角色")
@Table("sys_role")
@TransDefaultSett(defaultFields = {"name"})
public class RoleDo extends BaseEntity implements Serializable, TransPojo {

  @Serial private static final long serialVersionUID = 1L;

  /** 角色名称 */
  @Schema(title = "角色名称")
  private String name;

  /** 角色描述 */
  @Schema(title = "角色描述")
  private String description;

  /** 角色唯一key */
  @Schema(title = "角色唯一key")
  private String roleKey;

  /** 是否禁用: 0:启用 1:禁用 */
  @Schema(title = "是否禁用: 0:启用 1:禁用")
  private Integer disabled;

  public void checkRoleStatus() {
    USER_ROLE_DISABLE.equals(UserStatusEnum.NORMAL.getCode(), this.getDisabled());
  }
}
